//este aquivo contem as fun�oes para apresenta��o de dialogo
//interfaces que facilitao o uso das paginas po parte dos usuarios

//proxima fun��o apresenta um fumulario pronto, que ao cadastrar se destroi.. e sera manipulada

//fun��o para favorecidos

/*$(document).ready(function(){
			$('.Responsavel').click(function(){
			$('#dialog-responsavel').load("CadWindows",{
				//var codigo = $(this).attr("value")
				tipo: "responsavel"
			})})});*/

/*

$(document).ready(function(){
			$('.Responsavel').click(function(){
			$('#dialog-responsavel').load("CadWindows",{
				//var codigo = $(this).attr("value")
				tipo: "responsavel"
			},function(){$('#tab').tabs(),
			
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					nome = $("#nome"),
					funcao = $("#funcao"),
					nascimento = $( "#nascimento" ),
					cliente = $( "#cliente" ),
					//coloca as variaveis em um array para limpar os valores quando o form se fechar
					valors = $( [] ).add( nome ).add( funcao ).add( nascimento ).add( cliente );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-form" ).dialog({
						autoOpen: false,
						height: 540,
						minHeight: 540,
						maxHeight: 540,
						width: 1010,
						minWidth: 1010,
						maxWidth: 1010,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								valors.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( nome, "nome deve ter ", 1, 500 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados AlterarFavorecidoes
										 $.post("ResponsavelServlet",{ nome: nome.val(), funcao: funcao.val(),nascimento: nascimento.val(), cliente: cliente.val()
									        });
									   });
									$( this ).dialog( "close" );
								} $('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Cadastrar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							valors.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-form" ).dialog( "open" );
							
						}
				);
		});
	});
});

*/
$(document).ready(function(){
	$('.Responsavel').click(function(){
	$('#dialog-responsavel').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "responsavel",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
		//	tipo = $( "#responsavel" ),
			var categoria = $( "#cliente" ),
			//var	perfilLogado = $( "#responsavel" ),
			//conta = $( "#conta" ),
			//			favorecidos = $( "#favorecidos" ),
			//historico = $( "#historico" ),
			//	documento = $( "#documento" ),
			Valor = $( "#nome" ),
			dataEm = $( "#nascimento" ),
			numero = $( "#cargo" ),
			//meioPagamento = $( "#meioPagamento" ),
			//dataVem = $( "#dataVem" ),
			//frequencia = $( "#frequencia" ),
			//numeroSerie = $( "#numeroSerie" ),
			//codigoBarra = $( "#codigoBarra" ),
			//multa = $( "#multa" ),
			//juro = $( "#juro" ),
			//obs = $( "#obs" ),
			campos = $( [] ).add( categoria ).add( Valor ).add( dataEm ).add( numero ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
	            tips
	                .text( t )
	                .addClass( "ui-state-highlight" );
	            setTimeout(function() {
	                tips.removeClass( "ui-state-highlight", 5000 );
	            }, 2500 );
	        }
			 function checkLength( o, n, min, max ) {
		            if ( o.val().length > max || o.val().length < min ) {
		                o.addClass( "ui-state-error" );
		                updateTips( "Length of " + n + " must be between " +
		                    min + " and " + max + "." );
		                return false;
		            } else {
		                return true;
		            }
		        }
	        function checkRegexp( o, regexp, n ) {
	            if ( !( regexp.test( o.val() ) ) ) {
	                o.addClass( "ui-state-error" );
	                updateTips( n );
	                return false;
	            } else {
	                return true;
	            }
	        }
	 
	        $( "#dialog-responsavel" ).dialog({
	            autoOpen:false,
	            height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,
				modal: true,
	            buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
								 $.post("ResponsavelServlet",{categoria: categoria.val(), Valor: Valor.val(), dataEm: dataEm.val(), numero: numero.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-responsavel" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#nascimento").mask("99/99/9999");
					//	$("#dataVem").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
					$("#Valor").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});






/*****************************************************************************************************************************************/
/*****************************************************************************************************************************************/
/*****************************************************************************************************************************************/
/*****************************************************************************************************************************************/

$(document).ready(function(){
	$('.Cliente').click(function(){
	$('#dialog-cliente').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cliente",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#cliente" ),
			 razao= $( "#razao" ),
			 fantasia= $( "#fantasia" ),
			 responsavel= $( "#responsavel" ),
			 telefone= $( "#telefone" ),
			 numero= $( "#numero" ),
			 endereco= $( "#endereco" ),
			 honorario= $( "#honorario" ),
			 licenca= $( "#licenca" ),
			 dataCad= $( "#dataCad" ),
			 CNPJ= $( "#CNPJ" ),
			 IE= $( "#IE" ),
			 suframa= $( "#suframa" ),
			 ramo= $( "#ramo" ),
			 cidade = $( "#cidade" ),
			 bairro = $( "#bairro" ),
			
			campos = $( [] ).add( perfilLogado ).add( razao).add( fantasia).add( responsavel).add( telefone).add( numero ).add( endereco ).add( honorario).add( licenca).add( dataCad).add( CNPJ).add( IE).add( suframa).add( ramo).add( cidade).add( bairro),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-cliente" ).dialog({
				autoOpen: false,
				height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,	
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
			
								//envia os dados AlterarFavorecido
								 razao= $( "#razao" ),
								 fantasia= $( "#fantasia" ),
								 responsavel= $( "#responsavel" ),
								 telefone= $( "#telefone" ),
								 numero= $( "#numero" ),
								 endereco= $( "#endereco" ),
								 honorario= $( "#honorario" ),
								 licenca= $( "#licenca" ),
								 dataCad= $( "#dataCad" ),
								 CNPJ= $( "#CNPJ" ),
								 IE= $( "#IE" ),
								 suframa= $( "#suframa" ),
								 ramo= $( "#ramo" ),
								 cidade = $( "#cidade" ),
								 bairro = $( "#cidade" ),
								$.post("ClienteServlet",{perfilLogado: perfilLogado.val(),razao: razao.val(), fantasia: fantasia.val(), responsavel: responsavel.val(),telefone: telefone.val(), numero: numero.val(),endereco: endereco.val(), honorario: honorario.val(), licenca: licenca.val(),	dataCad: dataCad.val(), CNPJ: CNPJ.val(),IE: IE.val(), suframa: suframa.val(),ramo: ramo.val(),cidade: cidade.val(), bairro: bairro.val()});
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-cliente" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#dataCad").mask("99/99/9999");
						$("#CNPJ").mask("999.999.999-99");
				 	});
				}),$(document).ready(function(){
					$("#honorario").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
					$("#licenca").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});




/****************************************************************************************************************************************/
/****************************************************************************************************************************************/
/****************************************************************************************************************************************/
/****************************************************************************************************************************************/



$(document).ready(function(){
	$('.Funcionario').click(function(){
	$('#dialog-funcionario').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "funcionario",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#funcionario" ),
			 nome= $( "#nome" ),
			 cargo= $( "#cargo" ),
			 cnh= $( "#cnh" ),
			 telefone= $( "#telefone" ),
			 numero= $( "#numero" ),
			 endereco= $( "#endereco" ),
			 salario= $( "#salario" ),
			 dataAdm= $( "#dataAdm" ),
			 cpf= $( "#cpf" ),
			 cidade = $( "#cidade" ),
			 bairro = $( "#bairro" ),
			
			campos = $( [] ).add( perfilLogado ).add( nome).add( cargo).add( cnh).add( telefone).add( numero ).add( endereco ).add( salario).add( dataAdm).add( cpf).add( cidade).add( bairro),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-funcionario" ).dialog({
				autoOpen: false,
				height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,	
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
			
								//envia os dados AlterarFavorecido
								 nome= $( "#nome" ),
								 cargo= $( "#cargo" ),
								 cnh= $( "#cnh" ),
								 telefone= $( "#telefone" ),
								 numero= $( "#numero" ),
								 endereco= $( "#endereco" ),
								 salario= $( "#salario" ),
								 dataAdm= $( "#dataAdm" ),
								 cpf= $( "#cpf" ),
								 cidade = $( "#cidade" ),
								 bairro = $( "#bairro" ),
								$.post("FuncionarioServlet",{perfilLogado: perfilLogado.val(),nome: nome.val(), cargo: cargo.val(), cnh: cnh.val(),telefone: telefone.val(), numero: numero.val(),endereco: endereco.val(), salario: salario.val(), dataAdm: dataAdm.val(),cpf: cpf.val(),cidade: cidade.val(), bairro: bairro.val()});
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-funcionario" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#dataAdm").mask("99/99/9999");
						$("#cpf").mask("999.999.999-99");
				 	});
				}),$(document).ready(function(){
					$("#salario").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});


/*******************************************************************************************************************************/
/*******************************************************************************************************************************/
/*******************************************************************************************************************************/



$(document).ready(function(){
	$('.Veiculo').click(function(){
	$('#dialog-veiculo').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "veiculo",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#veiculo" ),
			tipo=$( "#tipo" ),
			marca=$( "#marca" ),
			modeloAno=$( "#modeloAno" ),
			kmInicial=$( "#kmInicial" ),
			funcionario=$( "#funcionario" ),
			pintura=$( "#pintura" ),
			pisca=$( "#pisca" ),
			buzina=$( "#buzina" ),
			motor=$( "#motor" ),
			lanterna=$( "#lanterna" ),
			farol=$( "#farol" ),
			pneus=$( "#pneus" ),
			obs=$( "#obs" ),
			campos = $( [] ).add( perfilLogado ).add( tipo).add( marca).add( modeloAno).add( kmInicial).add( funcionario).add( pintura).add( pisca).add( buzina).add( motor).add( lanterna).add( farol).add( pneus).add( obs),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-veiculo" ).dialog({
				autoOpen: false,
				height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,	
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
			
								//envia os dados AlterarFavorecido
								tipo=$( "#tipo" ),
								marca=$( "#marca" ),
								modeloAno=$( "#modeloAno" ),
								kmInicial=$( "#kmInicial" ),
								funcionario=$( "#funcionario" ),
								pintura=$( "#pintura" ),
								pisca=$( "#pisca" ),
								buzina=$( "#buzina" ),
								motor=$( "#motor" ),
								lanterna=$( "#lanterna" ),
								farol=$( "#farol" ),
								pneus=$( "#pneus" ),
								obs=$( "#obs" ),
								$.post("VeiculoServlet",{perfilLogado: perfilLogado.val(),tipo: tipo.val(),marca: marca.val(), modeloAno: modeloAno.val(),kmInicial: kmInicial.val(), funcionario: funcionario.val(),pintura: pintura.val(), pisca: pisca.val(), buzina: buzina.val(),motor: motor.val(),lanterna: lanterna.val(), farol: farol.val(),pneus: pneus.val(), obs: obs.val()});});
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-veiculo" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#modeloAno").mask("9999/9999");
						//$("#cpf").mask("999.999.999-99");
				 	});
				}),$(document).ready(function(){
					//$("#salario").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});


/*******************************************************************************************************************************/
/*******************************************************************************************************************************/
/*******************************************************************************************************************************/



$(document).ready(function(){
	$('.Bairro').click(function(){
	$('#dialog-bairro').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "bairro",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		 $(function() {
		        var nome= $( "#nome" ),
		        cidade = $( "#cidade" ),
		            allFields = $( [] ).add( nome).add( cidade),
		            tips = $( ".validateTips" );
		 
		        function updateTips( t ) {
		            tips
		                .text( t )
		                .addClass( "ui-state-highlight" );
		            setTimeout(function() {
		                tips.removeClass( "ui-state-highlight", 1500 );
		            }, 500 );
		        }
		 
		        function checkLength( o, n, min, max ) {
		            if ( o.val().length > max || o.val().length < min ) {
		                o.addClass( "ui-state-error" );
		                updateTips( "Length of " + n + " must be between " +
		                    min + " and " + max + "." );
		                return false;
		            } else {
		                return true;
		            }
		        }
		 
		        function checkRegexp( o, regexp, n ) {
		            if ( !( regexp.test( o.val() ) ) ) {
		                o.addClass( "ui-state-error" );
		                updateTips( n );
		                return false;
		            } else {
		                return true;
		            }
		        }
		 
		        $( "#dialog-form" ).dialog({
		            autoOpen: false,
		            height: 300,
		            width: 350,
		            modal: true,
		            buttons: {
		                "Create an account": function() {
		                    var bValid = true;
		                    if ( bValid ) {
		                        $( "#users tbody" ).append( "<tr>" +
		                            "<td>" + nome.val() + "</td>" + 
		                            "<td>" + cidade.val() + "</td>" + 
		                        "</tr>" ); 
		                        $( this ).dialog( "close" );
		                    }
		                },
		                Cancel: function() {
		                    $( this ).dialog( "close" );
		                }
		            },
		            close: function() {
		                allFields.val( "" ).removeClass( "ui-state-error" );
		            }
		        });
		 
		        $( "#create-user" )
		            .button()
		            .click(function() {
		                $( "#dialog-form" ).dialog( "open" );
		            });
		    });	});
});});


/*******************************************************************************************************************************/
/*******************************************************************************************************************************/
/*******************************************************************************************************************************/

/*
$(document).ready(function(){
	$('.cadastroConta').click(function(){
	$('#dialog-conta').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadConta",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#perfilLogadoConta" ),
			nome = $( "#name" ),
			tipoConta = $( "#tipoConta" ),
			banco = $( "#banco" ),
			agencia = $( "#agencia" ),
			numeroConta = $( "#numeroConta" ),
			data = $( "#data" ),
			valor = $( "#valor" ),
			limite = $("#limite"),
			dataVencLimit = $( "#dataVencLimit" ),
			obs = $( "#obs" ),
			campos = $( [] ).add( perfilLogado ).add( nome ).add( tipoConta ).add( banco ).add( agencia ).add( numeroConta ).add( data ).add( valor ).add( limite ).add( dataVencLimit ).add( obs ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-conta" ).dialog({
				autoOpen: false,
				height: 520,
				minHeight: 520,
				maxHeight: 520,
				width: 530,
				minWidth: 530,
				maxWidth: 530,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkRegexp( valor,/^([0-9])+$/i, "Por favor informe um valor e apenas n�meros");
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido AdicionaConta
										$.post("AdicionaConta",{perfilLogado: perfilLogado.val(), nome: nome.val(), tipoConta: tipoConta.val(),	banco: banco.val(), agencia: agencia.val(), numeroConta: numeroConta.val(),	data: data.val(), valor: valor.val(), limite: limite.val(), dataVencLimit: dataVencLimit.val(), obs: obs.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-conta" ).dialog( "open" );
					
				},$(document).ready(function(){
					$(function(){
						$("#valor").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						$("#limite").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
					});
					}),$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#data").mask("99/99/9999");
						$("#dataVencLimit").mask("99/99/9999");
				 	});
				}));
		});
	});
});

$(document).ready(function(){
	$('.cadConta').click(function(){
	$('#dialog-conta').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadConta",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#perfilLogadoConta" ),
			nome = $( "#name" ),
			tipoConta = $( "#tipoConta" ),
			banco = $( "#banco" ),
			agencia = $( "#agencia" ),
			numeroConta = $( "#numeroConta" ),
			data = $( "#data" ),
			valor = $( "#valor" ),
			limite = $("#limite"),
			dataVencLimit = $( "#dataVencLimit" ),
			obs = $( "#obs" ),
			campos = $( [] ).add( perfilLogado ).add( nome ).add( tipoConta ).add( banco ).add( agencia ).add( numeroConta ).add( data ).add( valor ).add( limite ).add( dataVencLimit ).add( obs ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-conta" ).dialog({
				autoOpen: false,
				height: 520,
				minHeight: 520,
				maxHeight: 520,
				width: 530,
				minWidth: 530,
				maxWidth: 530,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkRegexp( valor,/^([0-9])+$/i, "Por favor informe um valor e apenas n�meros");
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido AdicionaConta
										$.post("AdicionaConta",{perfilLogado: perfilLogado.val(), nome: nome.val(), tipoConta: tipoConta.val(),	banco: banco.val(), agencia: agencia.val(), numeroConta: numeroConta.val(),	data: data.val(), valor: valor.val(), limite: limite.val(), dataVencLimit: dataVencLimit.val(), obs: obs.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-conta" ).dialog( "open" );
					
				},$(document).ready(function(){
					$(function(){
						$("#valor").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						$("#limite").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
					});
					}),$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#data").mask("99/99/9999");
						$("#dataVencLimit").mask("99/99/9999");
				 	});
				}));
		});
	});
});

$(document).ready(function(){
	$('.cadastroContaAPagar').click(function(){
	$('#dialog-contaAPagar').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadContaAPagar",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#perfilLogadoAPagar" ),
			tipo = $( "#tipoP" ),
			categoria = $( "#categoria" ),
			conta = $( "#conta" ),
			favorecidos = $( "#favorecidos" ),
			historico = $( "#historico" ),
			documento = $( "#documento" ),
			Valor = $( "#Valor" ),
			dataEm = $( "#dataEm" ),
			numero = $( "#numero" ),
			meioPagamento = $( "#meioPagamento" ),
			dataVem = $( "#dataVem" ),
			frequencia = $( "#frequencia" ),
			numeroSerie = $( "#numeroSerie" ),
			codigoBarra = $( "#codigoBarra" ),
			multa = $( "#multa" ),
			juro = $( "#juro" ),
			obs = $( "#obs" ),
			campos = $( [] ).add( perfilLogado ).add( tipo ).add( categoria ).add( conta ).add( favorecidos ).add( historico ).add( documento ).add( Valor ).add( dataEm ).add( numero ).add( meioPagamento ).add( dataVem ).add( frequencia ).add( numeroSerie ).add( codigoBarra ).add( multa ).add( juro ).add( obs ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-contaAPagar" ).dialog({
				autoOpen: false,
				height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
								 $.post("AdicionaContaAPagarReceber",{perfilLogado: perfilLogado.val(), tipo: tipo.val(), categoria: categoria.val(), conta: conta.val(), favorecidos: favorecidos.val(), historico: historico.val(),	documento: documento.val(), Valor: Valor.val(), dataEm: dataEm.val(), numero: numero.val(), meioPagamento: meioPagamento.val(), dataVem: dataVem.val(), frequencia: frequencia.val(),numeroSerie: numeroSerie.val(), codigoBarra: codigoBarra.val(), multa: multa.val(), juro: juro.val(), obs: obs.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-contaAPagar" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#dataEm").mask("99/99/9999");
						$("#dataVem").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
					$("#Valor").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});

$(document).ready(function(){
	$('.cadastroContaAReceber').click(function(){
	$('#dialog-contaAReceber').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadContaAReceber",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	perfilLogado = $( "#perfilLogadoAReceber" ),
			tipo = $( "#tipoR" ),
			categoria = $( "#categoria" ),
			conta = $( "#conta" ),
			favorecidos = $( "#favorecidos" ),
			historico = $( "#historico" ),
			documento = $( "#documento" ),
			Valor = $( "#ValorR" ),
			dataEm = $( "#dataEmR" ),
			numero = $( "#numero" ),
			meioPagamento = $( "#meioPagamento" ),
			dataVem = $( "#dataVemR" ),
			frequencia = $( "#frequencia" ),
			numeroSerie = $( "#numeroSerie" ),
			codigoBarra = $( "#codigoBarra" ),
			multa = $( "#multa" ),
			juro = $( "#juro" ),
			obs = $( "#obs" ),
			campos = $( [] ).add( perfilLogado ).add( tipo ).add( categoria ).add( conta ).add( favorecidos ).add( historico ).add( documento ).add( Valor ).add( dataEm ).add( numero ).add( meioPagamento ).add( dataVem ).add( frequencia ).add( numeroSerie ).add( codigoBarra ).add( multa ).add( juro ).add( obs ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-contaAReceber" ).dialog({
				autoOpen: false,
				height: 515,
				minHeight: 515,
				maxHeight: 515,
				width: 770,
				minWidth: 770,
				maxWidth: 770,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( Valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
										$.post("AdicionaContaAPagarReceber",{perfilLogado: perfilLogado.val(), tipo: tipo.val(), categoria: categoria.val(), conta: conta.val(), favorecidos: favorecidos.val(), historico: historico.val(),	documento: documento.val(), Valor: Valor.val(), dataEm: dataEm.val(), numero: numero.val(), meioPagamento: meioPagamento.val(), dataVem: dataVem.val(), frequencia: frequencia.val(),numeroSerie: numeroSerie.val(), codigoBarra: codigoBarra.val(), multa: multa.val(), juro: juro.val(), obs: obs.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-contaAReceber" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#dataEmR").mask("99/99/9999");
						$("#dataVemR").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
				$("#ValorR").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
			}));
		});
	});
});

//fun��o para cadastro de contasAReceber

$(document).ready(function(){
	$('.cadastroContaAReceber').click(function(){
	$('#dialog-contaAReceber').load('favorecido'); 
	});
});

$(document).ready(function(){
	$('.lancamentoPagar').click(function(){
	$('#dialog-lancamentoPagar').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadLancamentoPagar",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	tipo = $( "#tipoLP" ),
			conta = $( "#conta" ),
			favorecidos = $( "#favorecid" ),
			categoria = $( "#categoria" ),
			historico = $( "#historico" ),
			data = $( "#datalp" ),
			numero = $( "#numero" ),
			valor = $( "#Valorlp" ),
			nominadoPara = $( "#nominadoPara" ),
			autentificacao = $( "#autentificacao" ),
			compensacao = $( "#dataCompensacao" ),
			observacao = $( "#observacao" ),
			campos = $( [] ).add( tipo ).add( conta ).add( favorecidos ).add( categoria ).add( historico ).add( data ).add( numero ).add( valor ).add( nominadoPara ).add( autentificacao ).add( compensacao ).add( observacao ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-lancamentoPagar" ).dialog({
				autoOpen: false,
				height: 530,
				minHeight: 530,
				maxHeight: 530,
				width: 520,
				minWidth: 520,
				maxWidth: 520,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
								$.post("LancamentosServlet",{tipo: tipo.val(), conta: conta.val(), favorecidos: favorecidos.val(), categoria: categoria.val(), historico: historico.val(), data: data.val(), numero: numero.val(),	valor: valor.val(), nominadoPara: nominadoPara.val(), autentificacao: autentificacao.val(),	compensacao: compensacao.val(), observacao: observacao.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-lancamentoPagar" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#datalp").mask("99/99/9999");
						$("#dataCompensacao").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
					$("#Valorlp").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});

$(document).ready(function(){
	$('.lancamentoReceber').click(function(){
	$('#dialog-lancamentoReceber').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadLancamentoReceber",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	tipo = $( "#tipoLR" ),
			conta = $( "#conta" ),
			favorecidos = $( "#favorecid" ),
			categoria = $( "#categoria" ),
			historico = $( "#historico" ),
			data = $( "#datalp" ),
			numero = $( "#numero" ),
			valor = $( "#Valorlp" ),
			nominadoPara = $( "#nominadoPara" ),
			autentificacao = $( "#autentificacao" ),
			compensacao = $( "#dataCompensacao" ),
			observacao = $( "#observacao" ),
			campos = $( [] ).add( tipo ).add( conta ).add( favorecidos ).add( categoria ).add( historico ).add( data ).add( numero ).add( valor ).add( nominadoPara ).add( autentificacao ).add( compensacao ).add( observacao ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-lancamentoReceber" ).dialog({
				autoOpen: false,
				height: 530,
				minHeight: 530,
				maxHeight: 530,
				width: 520,
				minWidth: 520,
				maxWidth: 520,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
								$.post("LancamentosServlet",{tipo: tipo.val(), conta: conta.val(), favorecidos: favorecidos.val(), categoria: categoria.val(), historico: historico.val(), data: data.val(), numero: numero.val(),	valor: valor.val(), nominadoPara: nominadoPara.val(), autentificacao: autentificacao.val(),	compensacao: compensacao.val(), observacao: observacao.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-lancamentoReceber" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#datalp").mask("99/99/9999");
						$("#dataCompensacao").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
					$("#Valorlp").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});

$(document).ready(function(){
	$('.Transferencia').click(function(){
	$('#dialog-lancamentoTransferencia').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "cadTransferencia",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var	tipo = $( "#tipoT" ),
			conta1 = $( "#conta1" ),
			historico = $( "#historico" ),
			data = $( "#datatrans" ),
			numero = $( "#numero" ),
			conta2 = $( "#conta2" ),
			valor = $( "#Valortrans" ),
			compensacao = $( "#dataCompensacaoT" ),
			observacao = $( "#observacao" ),
			campos = $( [] ).add( tipo ).add( conta1 ).add( historico ).add( data ).add( numero ).add( conta2 ).add( valor ).add( compensacao ).add( observacao ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho do " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-lancamentoTransferencia" ).dialog({
				autoOpen: false,
				height: 430,
				minHeight: 430,
				maxHeight: 430,
				width: 520,
				minWidth: 520,
				maxWidth: 520,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
									//envia os dados AlterarFavorecido
								$.post("TransferenciaServlet",{tipo: tipo.val(), conta1: conta1.val(), historico: historico.val(), data: data.val(), numero: numero.val(),	conta2: conta2.val(), valor: valor.val(),	compensacao: compensacao.val(), observacao: observacao.val()
							        });
							   });
							$( this ).dialog( "close" );
						} $('.conteudoTable').load("MessagemAlteracao",{
				    		//var codigo = $(this).attr("value")
				    		codigo: "Cadastrar"
				    	});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-lancamentoTransferencia" ).dialog( "open" );
					
				},$(document).ready(function(){ 
					$(function(){
						$.mask.addPlaceholder("~","[+-]");
						$("#datatrans").mask("99/99/9999");
						$("#dataCompensacaoT").mask("99/99/9999");
				 	});
				}),$(document).ready(function(){
					$("#Valortrans").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
				}));
		});
	});
});


//--- fim funcoes lancamentos----

//apresenta uma caixa de dialogo, efeitos sanfona, abas...
$(function(){
	$("#accordion").accordion({ header: "h3" });
	$('#tabs').tabs();
	$('#tab').tabs();
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"Ok": function() {
				$(this).dialog("close");
			}, 
			"Cancel": function() {
				$(this).dialog("close");
			} 
		}
	});
	$('#dialog_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	$('#datepicker').datepicker({
		inline: true
	});
	$('#slider').slider({
		range: true,
		values: [17, 67]
	});
	$("#progressbar").progressbar({
		value: 20
	});
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
});

$(document).ready(function(){ 
	$(function(){
		$.mask.addPlaceholder("~","[+-]");
		$("#telefone").mask("(99) 9999-9999");
		$("#celular").mask("(99) 9999-9999");
		$("#fax").mask("(99) 9999-9999");
		$("#cep").mask("99999-999");
		$("#data").mask("99/99/9999");
		$("#dataEm").mask("99/99/9999");
		$("#dataEmR").mask("99/99/9999");
		$("#dataVem").mask("99/99/9999");
		$("#dataVemR").mask("99/99/9999");
		$("#dataNasc").mask("99/99/9999");
		$("#datatrans").mask("99/99/9999");
		$("#dataVencLimit").mask("99/99/9999");
		$("#dataCompensacao").mask("99/99/9999");
		$("#dataCompensacaoT").mask("99/99/9999");
		$("#datalp").mask("99/99/9999");
		$("#cpf").mask("999.999.999-99");
		$("#cnpj").mask("99.999.999/9999-99");
 	});
});		  
$(document).ready(function(){
$('#estados').change(function(){
$('#cidades').load('cidades?estados='+$('#estados').val() );
});
});
$(document).ready(function(){
$('#perfil').click(function(){
$('.apresenteForm').load("perfil", function(){
$("#data").mask("99/99/9999"); 

});
});
});

//$(document).ready(function(){
	{//configura��es uteis
		  symbol:'US$', // Simbolo
		  decimal:'.', // Separador do decimal
		  precision:2, // Precis�o
		  thousands:',', // Separador para os milhares
		  allowZero:false, // Permite que o digito 0 seja o primeiro caractere
		  showSymbol:false // Exibe/Oculta o s�mbolo
	}
	// Configura��o padr�o.
	//$("#currency").maskMoney();

	// Configura��o para campos de Real.
	//$("#Valor").maskMoney({showSymbol:true, symbol:"R$", decimal:",", thousands:"."});
	//$("#ValorR").maskMoney({showSymbol:true, symbol:"R$", decimal:",", thousands:"."});

	// Configura��o para mudar a precis�o da m�scara. Neste caso a m�scara ir� aceitar 3 d�gitos ap�s a virgula.
	//$("#precision").maskMoney({precision:3})
//});
//function permite digitar apenas numeros
$(document).ready(
		 function() {
		 $("#txtName").bind('keyup blur', function(e){
		 e.preventDefault();
		    if(this.value.match(/[a-zA-Z]/g))
		      {
		           this.value = this.value.replace(/[a-zA-Z]/g,'');
		      }
      });
});
//permitir somente letras
$(document).ready(
function() {
    $("#txtName").bind('keyup blur', function(e){
        e.preventDefault();
        if(this.value.match(/[0-9]/g))
        {
            this.value = this.value.replace(/[0-9]/g,'');
        }
    });
});

//fun�oes para editar....................................................
$(document).ready(function(){
	$('#favorecido').click(function(){
	$('.conteudoTable').load("favorecido",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs(),
		
		$(document).ready(function(){
			$('.perfil1').click(function(){
			$('#dialog-FavorEdit').load("FavorecidoExternalServlet",{
				//var codigo = $(this).attr("value")//input:radio:checked //input[name='sexo']
				codigo:$(this).attr("value")
			},function(){$('#tab').tabs(),
			//"'input[name=sexo]:radio'"
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					var perfilLogado = $("#perfilLogadoFE"),
					perfil = $("#perfilFE"),
					favorecido = $("#favorecidoFE"),
					codigoEndereco = $("#enderecoFE"),
					codigoBanco = $("#codigoBancoFE"),
					pessoa = $("#pess"),
					sexo = $("#sex"),
					nome = $( "#nomeFE" ),
					rg = $( "#rgFE" ),
					cpf = $( "#cpfFE" ),
					dataNasc = $( "#dataNascFE" ),
					email = $( "#emailFE" ),
					telefone = $( "#telefoneFE" ),
					celular = $( "#celularFE" ),
					fax = $( "#faxFE" ),
					favorecidoObs = $( "#favorecidoObsFE" ),
					cidades = $( "#cidad" ),
					rua = $( "#ruaFE" ),
					bairro = $( "#bairroFE" ),
					numero = $( "#numeroFE" ),
					cep = $( "#cepFE" ),
					contas = $( "#conts" ),
					bancos = $( "#bancs" ),
					bancoAgencia = $( "#bancoAgenciaFE" ),
					bancoNumConta = $( "#bancoNumContaFE" ),
					bancoObs = $( "#bancoObsFE" ),
					tips = $( ".validateTipsFE" ),
					//coloca as variaveis em um array para limpar os valores quando o form se fechar
					valors = $( [] ).add( perfilLogado ).add( perfil ).add( favorecido ).add( codigoEndereco ).add( codigoBanco ).add( pessoa ).add( sexo ).add( nome ).add( rg ).add( cpf ).add( dataNasc ).add( email ).add( telefone ).add( celular ).add( fax ).add( favorecidoObs ).add( cidades ).add( rua ).add( bairro ).add( numero ).add( cep ).add( contas ).add( bancos ).add( bancoAgencia ).add( bancoNumConta ).add( bancoObs );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-FavorEdit" ).dialog({
						autoOpen: false,
						height: 500,
						minHeight: 500,
						maxHeight: 500,
						width: 1008,
						minWidth: 1008,
						maxWidth: 1008,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								valors.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados AlterarFavorecido
												$.post("AlterarFavorecido",{ perfilLogado: perfilLogado.val(), perfil: perfil.val(), favorecido: favorecido.val(),codigoEndereco: codigoEndereco.val(),codigoBanco: codigoBanco.val(), pessoa: pessoa.val(), sexo: sexo.val(),nome: nome.val(), rg: rg.val(), cpf: cpf.val(), dataNasc: dataNasc.val(), telefone: telefone.val(), celular: celular.val(), fax: fax.val(), email: email.val(), favorecidoObs: favorecidoObs.val(), cidades: cidades.val(), rua: rua.val(), bairro: bairro.val(), numero: numero.val(), cep: cep.val(), contas: contas.val(), bancos: bancos.val(), bancoAgencia: bancoAgencia.val(), bancoNumConta: bancoNumConta.val(), bancoObs: bancoObs.val()
									        });
									   });
									$( this ).dialog( "close" );
								} $('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							valors.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-FavorEdit" ).dialog( "open" );
							
						},$(document).ready(function(){
							$('#estad').change(function(){
								$('#cidad').load('cidades?estados='+$('#estad').val() );
								});
								}),$(document).ready(function(){ 
									$(function(){
										$.mask.addPlaceholder("~","[+-]");
										$("#telefoneFE").mask("(99) 9999-9999");
										$("#celularFE").mask("(99) 9999-9999");
										$("#faxFE").mask("(99) 9999-9999");
										$("#cepFE").mask("99999-999");
										$("#dataNascFE").mask("99/99/9999");
										$("#cpfFE").mask("999.999.999-99");
										$("#cnpj").mask("99.999.999/9999-99");
								 	});
								}));
					});
				});
			},$(document).ready(function (){
				$('.delet').click(function(){
					codigo = $(this).attr("value")
					$(function() {
							// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
							$( "#dialog:ui-dialog" ).dialog( "destroy" );
							$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Tem certeza que deseja excluir o item?</p>');
							$( "#dialog-confirm" ).dialog({
								resizable: false,
								modal: true,
								buttons: {
									"Confirmar": function() {
										$.post("DeletarExcluirServlet",{codigo: codigo, funcao: "Deletar", tip: "favorecido"},$('.conteudoTable').load("MessagemAlteracao",{
											codigo: "Deletar"
										}));
										$( this ).dialog( "close" );
									},
									"Cancelar": function() {
										$( this ).dialog( "close" );
									}
								}
							});
						});
					});
				}));
		});
	});
});


$(document).ready(function(){
	$('.ListaLancamentos').click(function(){
		$('.conteudoTable').load("Lancamentos",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs()});
	});
});


$(document).ready(function(){
	$('.ListaConta').click(function(){
		$('.conteudoTable').load("ContasPagarReceber",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs(),
		
		$(document).ready(function(){
			$('.cont').click(function(){
			$('#dialog-RP').load("ContaExternalPRServlet",{
				//var codigo = $(this).attr("value")
				codigo:$(this).attr("value"),
				tip:$("#tip").val()
			},function(){$('#tabpr').tabs(),
			
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					var contaPagarReceber = $("#contaPagarReceberPR"),
						types = $("#cprTipo"),
						categoria = $("#categoriaPR"),
						conta = $( "#contaPR" ),
						favorecidos = $( "#favorecidosPR" ),
						historico = $("#historicoPR"),
						documento = $("#documentoPR"),
						valor = $("#ValorPR"),
						data = $("#dataPR"),
						numero = $("#numeroPR"),
						meioPagamento = $("#meioPagamentoPR"),
						dataVem = $("#dataVemPR"),
						frequencia = $("#frequenciaPR"),
						numeroSerie = $("#numeroSeriePR"),
						codigoBarra = $("#codigoBarraPR"),
						multa = $("#multaPR"),
						juro = $("#juroPR"),
						obs = $("#obsPR"),
						campos = $( [] ).add( contaPagarReceber ).add( types ).add( categoria ).add( conta ).add( favorecidos ).add( historico ).add( documento ).add( valor ).add( data ).add( numero ).add( meioPagamento ).add( dataVem ).add( frequencia ).add( numeroSerie ).add( codigoBarra ).add( multa ).add( juro ).add( obs ),
						tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-RP" ).dialog({
						autoOpen: false,
						height: 500,
						minHeight: 500,
						maxHeight: 500,
						width: 760,
						minWidth: 760,
						maxWidth: 760,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
									        $.post("EditarContaAPagarReceber",{contaPagarReceber: contaPagarReceber.val(), types: types.val(), categoria: categoria.val(), conta: conta.val(), favorecidos: favorecidos.val(), historico: historico.val(), documento: documento.val(), valor: valor.val(), data: data.val(), numero: numero.val(), numero: numero.val(),meioPagamento: meioPagamento.val(), dataVem: dataVem.val(), frequencia: frequencia.val(),numeroSerie: numeroSerie.val(), codigoBarra: codigoBarra.val(),multa: multa.val(), juro: juro.val(), obs: obs.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-RP" ).dialog( "open" );
							
						},$(document).ready(function(){ 
							$(function(){
								$.mask.addPlaceholder("~","[+-]");
								$("#dataPR").mask("99/99/9999");
								$("#dataVemPR").mask("99/99/9999");
						 	});
						}),$(document).ready(function(){
							$("#ValorPR").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						}));
					});
				});
			},$(document).ready(function (){
				$('.delet').click(function(){
					codigo = $(this).attr("value")
					$(function() {
							// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
							$( "#dialog:ui-dialog" ).dialog( "destroy" );
							$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Tem certeza que deseja excluir o item?</p>');
							$( "#dialog-confirm" ).dialog({
								resizable: false,
								modal: true,
								buttons: {
									"Confirmar": function() {
										$.post("DeletarExcluirServlet",{codigo: codigo, funcao: "Deletar", tip: "contaPR"},$('.conteudoTable').load("MessagemAlteracao",{
											codigo: "Deletar"
										}));
										$( this ).dialog( "close" );
									},
									"Cancelar": function() {
										$( this ).dialog( "close" );
									}
								}
							});
						});
					});
				}),$(document).ready(function(){
					$('.liquid').click(function(){
						codigo = $(this).attr("value")

						$('#dialog-RP').load("ContaExternalPRServlet",{
							//var codigo = $(this).attr("value")
							codigo:$(this).attr("value"),
							tip:$("#tip").val()
						},function(){$('#tabpr').tabs(),
						
							$(function() {
								// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
								$( "#dialog:ui-dialog" ).dialog( "destroy" );
								var contaPagarReceber = $("#contaPagarReceberPR"),
									typ = $("#cprTipo"),
									categoria = $("#categoriaPR"),
									conta = $( "#contaPR" ),
									favorecidos = $( "#favorecidosPR" ),
									historico = $("#historicoPR"),
									documento = $("#documentoPR"),
									valor = $("#ValorPR"),
									data = $("#dataPR"),
									numero = $("#numeroPR"),
									meioPagamento = $("#meioPagamentoPR"),
									dataVem = $("#dataVemPR"),
									frequencia = $("#frequenciaPR"),
									numeroSerie = $("#numeroSeriePR"),
									codigoBarra = $("#codigoBarraPR"),
									multa = $("#multaPR"),
									juro = $("#juroPR"),
									obs = $("#obsPR"),
									campos = $( [] ).add( contaPagarReceber ).add( typ ).add( categoria ).add( conta ).add( favorecidos ).add( historico ).add( documento ).add( valor ).add( data ).add( numero ).add( meioPagamento ).add( dataVem ).add( frequencia ).add( numeroSerie ).add( codigoBarra ).add( multa ).add( juro ).add( obs ),
									tips = $( ".validateTips" );

								function updateTips( t ) {
									tips
										.text( t )
										.addClass( "ui-state-highlight" );
									setTimeout(function() {
										tips.removeClass( "ui-state-highlight", 1500 );
									}, 500 );
								}

								function checkLength( o, n, min, max ) {
									if ( o.val().length > max || o.val().length < min ) {
										o.addClass( "ui-state-error" );
										updateTips( "Tamanho do " + n + " deve estar entre " +
											min + " e " + max + " caracteres." );
										return false;
									} else {
										return true;
									}
								}

								function checkRegexp( o, regexp, n ) {
									if ( !( regexp.test( o.val() ) ) ) {
										o.addClass( "ui-state-error" );
										updateTips( n );
										return false;
									} else {
										return true;
									}
								}
								$( "#dialog-RP" ).dialog({
									autoOpen: false,
									height: 500,
									minHeight: 500,
									maxHeight: 500,
									width: 760,
									minWidth: 760,
									maxWidth: 760,
									modal: true,
									buttons: {
										"Liquidar": function() {
											var bValid = true;
											campos.removeClass( "ui-state-error" );

											bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
											//bValid = bValid && checkLength( email, "email", 6, 80 );
											//bValid = bValid && checkLength( password, "password", 5, 16 );

											//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
											// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
											//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
											//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

											if ( bValid ) {
												
												$(function(){
														//envia los dados
												        $.post("LiquidarContaAPagarReceber",{contaPagarReceber: contaPagarReceber.val(), typ: typ.val(), categoria: categoria.val(), conta: conta.val(), favorecidos: favorecidos.val(), historico: historico.val(), documento: documento.val(), valor: valor.val(), data: data.val(), numero: numero.val(), numero: numero.val(),meioPagamento: meioPagamento.val(), dataVem: dataVem.val(), frequencia: frequencia.val(),numeroSerie: numeroSerie.val(), codigoBarra: codigoBarra.val(),multa: multa.val(), juro: juro.val(), obs: obs.val()
												        });
												   });
												$( this ).dialog( "close" );
											}$('.conteudoTable').load("MessagemAlteracao",{
									    		//var codigo = $(this).attr("value")
									    		codigo: "Alterar"
									    	});
										},
										Cancel: function() {
											$( this ).dialog( "close" );
										}
									},
									close: function() {
										campos.val( "" ).removeClass( "ui-state-error" );
									}
								});
										$( "#dialog-RP" ).dialog( "open" );
										
									},$(document).ready(function(){ 
										$(function(){
											$.mask.addPlaceholder("~","[+-]");
											$("#dataPR").mask("99/99/9999");
											$("#dataVemPR").mask("99/99/9999");
									 	});
									}),$(document).ready(function(){
										$("#ValorPR").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
									}));
								});
					});
			}));
		
	});
	});
});


$(document).ready(function(){
	$('.ContasBanco').click(function(){
		$('.conteudoTable').load("ContaBanc",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs(),chartContaHistorico();		
	$(document).ready(function(){
			$('.contaBanc').click(function(){
			$('#dialog-ContaBanc').load("ContaBancExternalPRServlet",{
				//var codigo = $(this).attr("value")
				codigo:$(this).attr("value"),
				tip:$("#tip").val()
			},function(){$('#tabpr').tabs(),
				$(function() {
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					var contaBanco = $("#contaBancoCB"),
						nome = $("#nomeCB"),
						tipoConta = $("#tipoContaCB"),
						bancos = $("#bancosCB"),
						agencia = $("#agenciaCB"),
						numeroConta = $("#numeroContaCB"),
						data = $("#dataCB"),
						valor = $("#valorCB"),
						limite = $("#limiteCB"),
						dataVencLimit = $("#dataVencLimitCB"),
						obs = $("#obsCB"),
						campos = $( [] ).add( contaBanco ).add( nome ).add( tipoConta ).add( bancos ).add( agencia ).add( numeroConta ).add( data ).add( valor ).add( limite ).add( dataVencLimit ).add( obs ),
						tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-ContaBanc" ).dialog({
						autoOpen: false,
						height: 460,
						minHeight: 460,
						maxHeight: 460,
						width: 540,
						minWidth: 540,
						maxWidth: 540,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
									        $.post("EditarContaBanco",{contaBanco: contaBanco.val(), nome: nome.val(), tipoConta: tipoConta.val(), bancos: bancos.val(),agencia: agencia.val(), numeroConta: numeroConta.val(), data: data.val(),valor: valor.val(), limite: limite.val(),	dataVencLimit: dataVencLimit.val(),	obs: obs.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							} 
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-ContaBanc" ).dialog( "open" );
							
						},$(document).ready(function(){ 
							$(function(){
								$.mask.addPlaceholder("~","[+-]");
								$("#dataCB").mask("99/99/9999");
								$("#dataVencLimitCB").mask("99/99/9999");
						 	});
						}),$(document).ready(function(){
							$("#valorCB").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
							$("#limiteCB").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						}));
					});
				});
			},$(document).ready(function (){
				$('.delet').click(function(){
					codigo = $(this).attr("value")
					$(function() {
							// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
							$( "#dialog:ui-dialog" ).dialog( "destroy" );
							$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Tem certeza que deseja excluir o item?</p>');
							$( "#dialog-confirm" ).dialog({
								resizable: false,
								modal: true,
								buttons: {
									"Confirmar": function() {
										$.post("DeletarExcluirServlet",{codigo: codigo, funcao: "Deletar", tip: "conta"},$('.conteudoTable').load("MessagemAlteracao",{
											codigo: "Deletar"
										}));
										$( this ).dialog( "close" );
									},
									"Cancelar": function() {
										$( this ).dialog( "close" );
									}
								}
							});
						});
					});
				}));
		
		});
	});
});

$(document).ready(function(){
	$('.ListaTransferencia').click(function(){
		$('.conteudoTable').load("ListaTransferencia",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs(),
		
		$(document).ready(function(){
			$('.transferenc').click(function(){
			$('#dialog-Transferencia').load("TransferenciaExternalServlet",{
				//var codigo = $(this).attr("value")
				codigo:$(this).attr("value")
			},function(){$('#tabst').tabs(),
			
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					var codigo = $("#codigoTE"),
						tipo = $( "#tipoTE" ),
						conta1 = $( "#conta1TE" ),
						historico = $( "#historicoTE" ),
						data = $( "#datatransTE" ),
						numero = $( "#numeroTE" ),
						conta2 = $("#conta2TE"),
						valor = $( "#ValortransTE" ),
						compensacao = $( "#dataCompensacaoTE" ),
						observacao = $( "#observacaoTE" ),
						campos = $( [] ).add( codigo ).add( tipo ).add( conta1 ).add( historico ).add( data ).add( numero ).add( conta2 ).add( valor ).add( compensacao ).add( observacao ),
						tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-Transferencia" ).dialog({
						autoOpen: false,
						height: 460,
						minHeight: 460,
						maxHeight: 460,
						width: 540,
						minWidth: 540,
						maxWidth: 540,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
									        $.post("EditarTransferencia",{codigo: codigo.val(), tipo: tipo.val(), conta1: conta1.val(), historico: historico.val(), data: data.val(), numero: numero.val(),conta2: conta2.val(), valor: valor.val(), compensacao: compensacao.val(), observacao: observacao.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-Transferencia" ).dialog( "open" );
							
						},$(document).ready(function(){ 
							$(function(){
								$.mask.addPlaceholder("~","[+-]");
								$("#datatransTE").mask("99/99/9999");
								$("#dataCompensacaoTE").mask("99/99/9999");
						 	});
						}),$(document).ready(function(){
							$("#ValortransTE").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						}));
					});
				});
			},$(document).ready(function (){
				$('.delet').click(function(){
					codigo = $(this).attr("value")
					
					$(function() {
							// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
							$( "#dialog:ui-dialog" ).dialog( "destroy" );
							$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Tem certeza que deseja excluir o item?</p>');
							$( "#dialog-confirm" ).dialog({
								resizable: false,
								modal: true,
								buttons: {
									"Confirmar": function() {
										$.post("DeletarExcluirServlet",{codigo: codigo, funcao: "Deletar", tip: "transferencia"},$('.conteudoTable').load("MessagemAlteracao",{
											codigo: "Deletar"
										}));
										$( this ).dialog( "close" );
									},
									"Cancelar": function() {
										$( this ).dialog( "close" );
									}
								}
							});
						});
					});
				}));
		
	});
	});
});





$(document).ready(function(){
	$('.cadastroFavorecido').click(function(){
	$('.conteudoTable').load("FavorecidoExternalServlet",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),$(document).ready(function(){
		$('#estados').change(function(){
			$('#cidades').load('cidades?estados='+$('#estados').val() );
			});
			})});
	});
});


$(document).ready(function(){
	$('.ListaLancamentos').click(function(){
		$('.conteudoTable').load("Lancamentos",{
		//var codigo = $(this).attr("value")
		codigo:$("#Logado").val()
	},function(){$('#tabc').tabs(),		
		$(document).ready(function(){
			$('.lancamentoEdit').click(function(){
			$('#dialog-Lancamento').load("LancamentoExternalServlet",{
				//var codigo = $(this).attr("value")
				codigo:$(this).attr("value")
			},function(){$('#tablan').tabs(),
			
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog:ui-dialog" ).dialog( "destroy" );
					var codigoLanc = $("#codigoLanc"),
						tipo = $("#tipoLAC"),
						conta = $( "#contaLAC" ),
						favorecidos = $( "#favorecidLAC" ),
						categoria = $( "#categoriaLAC" ),
						historico = $( "#historicoLAC" ),
						data = $( "#datalpLAC" ),
						numero = $( "#numeroLAC" ),
						valor = $( "#ValorlpLAC" ),
						nominadoPara = $( "#nominadoParaLAC" ),
						autentificacao = $( "#autentificacaoLAC" ),
						compensacao = $( "#dataCompensacaoLAC" ),
						observacao = $( "#observacaoLAC" ),
						campos = $( [] ).add( codigoLanc ).add( tipo ).add( conta ).add( favorecidos ).add( categoria ).add( historico ).add( data ).add( numero ).add( valor ).add( nominadoPara ).add( autentificacao ).add( compensacao ).add( observacao ),
						tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-Lancamento" ).dialog({
						autoOpen: false,
						height: 480,
						minHeight: 480,
						maxHeight: 480,
						width: 540,
						minWidth: 540,
						maxWidth: 540,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
										$.post("EditarLancamento",{codigoLanc: codigoLanc.val(), tipo: tipo.val(), conta: conta.val(), favorecidos: favorecidos.val(), categoria: categoria.val(), historico: historico.val(), data: data.val(), numero: numero.val(),	valor: valor.val(), nominadoPara: nominadoPara.val(), autentificacao: autentificacao.val(),	compensacao: compensacao.val(), observacao: observacao.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-Lancamento" ).dialog( "open" );
							
						},$(document).ready(function(){ 
							$(function(){
								$.mask.addPlaceholder("~","[+-]");
								$("#datalpLAC").mask("99/99/9999");
								$("#dataCompensacaoLAC").mask("99/99/9999");
						 	});
						}),$(document).ready(function(){
							$("#ValorlpLAC").maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
						}));
					});
				});
			},$(document).ready(function (){
				$('.delet').click(function(){
					codigo = $(this).attr("value")
					
					$(function() {
						// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
						$( "#dialog:ui-dialog" ).dialog( "destroy" );
						$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Tem certeza que deseja excluir o item?</p>');
						$( "#dialog-confirm" ).dialog({
							resizable: false,
							modal: true,
							buttons: {
								"Confirmar": function() {
									$.post("DeletarExcluirServlet",{codigo: codigo, funcao: "Deletar", tip: "lancamento"},$('.conteudoTable').load("MessagemAlteracao",{
										codigo: "Deletar"
									}));
									$( this ).dialog( "close" );
								},
								"Cancelar": function() {
									$( this ).dialog( "close" );
								}
							}
						});
					});
					});
				}));
		
	});
	});
});


$(function() {
	$( "#tabp" ).tabs(),chartHistoricoFinaceiro();
});

$(document).ready(function(){
	$('.perfil').click(function(){
	$('.conteudoTable').load("ExibirPerfil",{
		codigo:$("#Logado").val(),
		typo: "iniPerfil",
	},function(){$('#tabp').tabs(), chartInici();  chartHom();
		
		$(document).ready(function(){
			$('.perfilLog').click(function(){
			$('#dialog-PerfilLog').load("PerfilLogin",{
				//var codigo = $(this).attr("value")
				codigo:$("#Logado").val(),
				typo: "iniInicio"
			},function(){$('#tabp').tabs(),
			
				$(function() {
					// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
					$( "#dialog-PerfilLog" ).dialog( "destroy" );
					var perfilLog = $("#perfilLogin"),
					enderecoCod = $("#enderecoLog"),
					sexo = $( "#sex" ),
					nome = $( "#nomePerf" ),
					rg = $( "#rgPerf" ),
					cpf = $( "#cpfPerf" ),
					data = $( "#dataNascPerf" ),
					email = $( "#emailPerf" ),
					fone = $( "#telefonePerf" ),
					fax = $( "#faxPerf" ),
					celular = $( "#celularPerf" ),
					estado = $( "#estad" ),
					cidade = $( "#cidad" ),
					rua = $( "#ruaPerf" ),
					bairro = $( "#bairroPerf" ),
					numero = $( "#numeroPerf" ),
					cep = $( "#cepPerf" ),
					campos = $( [] ).add( perfilLog ).add( enderecoCod ).add( sexo ).add( nome ).add( rg ).add( cpf ).add( data ).add( email ).add( fone ).add( fax ).add( celular ).add( estado ).add( cidade ).add( rua ).add( bairro ).add( numero ).add( cep ),
					tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-PerfilLog" ).dialog({
						autoOpen: false,
						height: 540,
						minHeight: 540,
						maxHeight: 540,
						width: 510,
						minWidth: 510,
						maxWidth: 510,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								//bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
										 $.post("EditarPerfilLogin",{perfilLog: perfilLog.val(), enderecoCod: enderecoCod.val(), sexo: sexo.val(), nome: nome.val(), rg: rg.val(), cpf: cpf.val(), data: data.val(), email: email.val(),	fone: fone.val(), fax: fax.val(), celular: celular.val(),	estado: estado.val(), cidade: cidade.val(), rua: rua.val(), bairro: bairro.val(),	numero: numero.val(), cep: cep.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-PerfilLog" ).dialog( "open" );
							
						},$(document).ready(function(){
							$('#estad').change(function(){
								$('#cidad').load('cidades?estados='+$('#estad').val() );
								});
								}),$(document).ready(function(){ 
									$(function(){
										$.mask.addPlaceholder("~","[+-]");
										$("#telefonePerf").mask("(99) 9999-9999");
										$("#celularPerf").mask("(99) 9999-9999");
										$("#faxPerf").mask("(99) 9999-9999");
										$("#cepPerf").mask("99999-999");
										$("#dataNascPerf").mask("99/99/9999");
										$("#cpfPerf").mask("999.999.999-99");
										$("#cnpj").mask("99.999.999/9999-99");
								 	});
								}));
					});
				});
			});
		});
	});
});
$(document).ready(function(){
	$('.inicio').click(function(){
	$('.conteudoTable').load("ExibirPerfil",{
		codigo:$("#Logado").val(),
		typo: "iniInicio"
	},function(){$('#tabp').tabs(), chartHome(),  chartHistoricoFinaceiro(),
		
		$(document).ready(function(){
			$('.perfilLog').click(function(){
			$('#dialog-PerfilLog').load("PerfilLogin",{
				codigo:$("#Logado").val(),
				typo: "iniInicio"
			},function(){$('#tabp').tabs(),
			
				$(function() {
					$( "#dialog-PerfilLog" ).dialog( "destroy" );
					var perfilLog = $("#perfilLogin"),
					enderecoCod = $("#enderecoLog"),
					sexo = $( "#sex" ),
					nome = $( "#nomePerf" ),
					rg = $( "#rgPerf" ),
					cpf = $( "#cpfPerf" ),
					data = $( "#dataNascPerf" ),
					email = $( "#emailPerf" ),
					fone = $( "#telefonePerf" ),
					fax = $( "#faxPerf" ),
					celular = $( "#celularPerf" ),
					estado = $( "#estad" ),
					cidade = $( "#cidad" ),
					rua = $( "#ruaPerf" ),
					bairro = $( "#bairroPerf" ),
					numero = $( "#numeroPerf" ),
					cep = $( "#cepPerf" ),
					campos = $( [] ).add( perfilLog ).add( enderecoCod ).add( sexo ).add( nome ).add( rg ).add( cpf ).add( data ).add( email ).add( fone ).add( fax ).add( celular ).add( estado ).add( cidade ).add( rua ).add( bairro ).add( numero ).add( cep ),
					tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-PerfilLog" ).dialog({
						autoOpen: false,
						height: 540,
						minHeight: 540,
						maxHeight: 540,
						width: 510,
						minWidth: 510,
						maxWidth: 510,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								//bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
										 $.post("EditarPerfilLogin",{perfilLog: perfilLog.val(), enderecoCod: enderecoCod.val(), sexo: sexo.val(), nome: nome.val(), rg: rg.val(), cpf: cpf.val(), data: data.val(), email: email.val(),	fone: fone.val(), fax: fax.val(), celular: celular.val(),	estado: estado.val(), cidade: cidade.val(), rua: rua.val(), bairro: bairro.val(),	numero: numero.val(), cep: cep.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		//var codigo = $(this).attr("value")
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-PerfilLog" ).dialog( "open" );
							
						},$(document).ready(function(){
							$('#estad').change(function(){
								$('#cidad').load('cidades?estados='+$('#estad').val() );
								});
								}),$(document).ready(function(){ 
									$(function(){
										$.mask.addPlaceholder("~","[+-]");
										$("#telefonePerf").mask("(99) 9999-9999");
										$("#celularPerf").mask("(99) 9999-9999");
										$("#faxPerf").mask("(99) 9999-9999");
										$("#cepPerf").mask("99999-999");
										$("#dataNascPerf").mask("99/99/9999");
										$("#cpfPerf").mask("999.999.999-99");
										$("#cnpj").mask("99.999.999/9999-99");
								 	});
								}));
					});
				});
			});
		});
	});
});

$(document).ready(function(){
			$('.perfilLog').click(function(){
			$('#dialog-PerfilLog').load("PerfilLogin",{
				//var codigo = $(this).attr("value")
				codigo:$("#Logado").val(),
				typo: "iniInicio"
			},function(){$('#tabp').tabs(),
			
				$(function() {
					$( "#dialog-PerfilLog" ).dialog( "destroy" );
					var perfilLog = $("#perfilLogin"),
						enderecoCod = $("#enderecoLog"),
						sexo = $( "#sex" ),
						nome = $( "#nomePerf" ),
						rg = $( "#rgPerf" ),
						cpf = $( "#cpfPerf" ),
						data = $( "#dataNascPerf" ),
						email = $( "#emailPerf" ),
						fone = $( "#telefonePerf" ),
						fax = $( "#faxPerf" ),
						celular = $( "#celularPerf" ),
						estado = $( "#estad" ),
						cidade = $( "#cidad" ),
						rua = $( "#ruaPerf" ),
						bairro = $( "#bairroPerf" ),
						numero = $( "#numeroPerf" ),
						cep = $( "#cepPerf" ),
						campos = $( [] ).add( perfilLog ).add( enderecoCod ).add( sexo ).add( nome ).add( rg ).add( cpf ).add( data ).add( email ).add( fone ).add( fax ).add( celular ).add( estado ).add( cidade ).add( rua ).add( bairro ).add( numero ).add( cep ),
						tips = $( ".validateTips" );

					function updateTips( t ) {
						tips
							.text( t )
							.addClass( "ui-state-highlight" );
						setTimeout(function() {
							tips.removeClass( "ui-state-highlight", 1500 );
						}, 500 );
					}

					function checkLength( o, n, min, max ) {
						if ( o.val().length > max || o.val().length < min ) {
							o.addClass( "ui-state-error" );
							updateTips( "Tamanho do " + n + " deve estar entre " +
								min + " e " + max + " caracteres." );
							return false;
						} else {
							return true;
						}
					}

					function checkRegexp( o, regexp, n ) {
						if ( !( regexp.test( o.val() ) ) ) {
							o.addClass( "ui-state-error" );
							updateTips( n );
							return false;
						} else {
							return true;
						}
					}
					$( "#dialog-PerfilLog" ).dialog({
						autoOpen: false,
						height: 540,
						minHeight: 540,
						maxHeight: 540,
						width: 510,
						minWidth: 510,
						maxWidth: 510,
						modal: true,
						buttons: {
							"Salvar": function() {
								var bValid = true;
								campos.removeClass( "ui-state-error" );

								//bValid = bValid && checkLength( valor, "valor deve ter ", 1, 16 );
								//bValid = bValid && checkLength( email, "email", 6, 80 );
								//bValid = bValid && checkLength( password, "password", 5, 16 );

								//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
								// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
								//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
								//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

								if ( bValid ) {
									
									$(function(){
											//envia os dados
									        $.post("EditarPerfilLogin",{perfilLog: perfilLog.val(), enderecoCod: enderecoCod.val(), sexo: sexo.val(), nome: nome.val(), rg: rg.val(), cpf: cpf.val(), data: data.val(), email: email.val(),	fone: fone.val(), fax: fax.val(), celular: celular.val(),	estado: estado.val(), cidade: cidade.val(), rua: rua.val(), bairro: bairro.val(),	numero: numero.val(), cep: cep.val()
									        });
									   });
									$( this ).dialog( "close" );
								}$('.conteudoTable').load("MessagemAlteracao",{
						    		codigo: "Alterar"
						    	});
							},
							Cancel: function() {
								$( this ).dialog( "close" );
							}
						},
						close: function() {
							campos.val( "" ).removeClass( "ui-state-error" );
						}
					});
							$( "#dialog-PerfilLog" ).dialog( "open" );
							
						},$(document).ready(function(){
							$('#estad').change(function(){
								$('#cidad').load('cidades?estados='+$('#estad').val() );
								});
								}),$(document).ready(function(){ 
									$(function(){
										$.mask.addPlaceholder("~","[+-]");
										$("#telefonePerf").mask("(99) 9999-9999");
										$("#celularPerf").mask("(99) 9999-9999");
										$("#faxPerf").mask("(99) 9999-9999");
										$("#cepPerf").mask("99999-999");
										$("#dataNascPerf").mask("99/99/9999");
										$("#cpfPerf").mask("999.999.999-99");
										$("#cnpj").mask("99.999.999/9999-99");
								 	});
								}));
					});
				});
});

$(document).ready(function(){
	$('.alteralLogin').click(function(){
	$('#dialog-AlterarLog').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "alterarLogin",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var codigoLog = $( "#codigoLog" ),	
			senhaAtual = $( "#senhaAtual" ),
			NovaSenha = $( "#NovaSenha" ),
			ConfirmSenha = $( "#ConfirmSenha" ),
			campos = $( [] ).add( codigoLog ).add( senhaAtual ).add( NovaSenha ).add( ConfirmSenha ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho da " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-AlterarLog" ).dialog({
				autoOpen: false,
				height: 360,
				minHeight: 360,
				maxHeight: 360,
				width: 270,
				minWidth: 270,
				maxWidth: 270,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( NovaSenha, " senha ", 6, 20 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
								 $.post("AlterarLogin",{codigoLog: codigoLog.val(), senhaAtual: senhaAtual.val(), NovaSenha: NovaSenha.val(), ConfirmSenha: ConfirmSenha.val()
							        },$('.conteudoTable').load("MessagemAlteracao",{
							    		codigo: "Alterar"
							    	}));
							   });
							$( this ).dialog( "close" );
						} 
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-AlterarLog" ).dialog( "open" );
					
				},$(document).ready(function(){
					$('#formulario').validate({
						rules:{
							senhaAtual:{ required: true, remote: 'VerificarLogin?codigoLog='+$('#codigoLog').val() },
							ConfirmSenha: {
                                required: true,
                                equalTo: "#NovaSenha"
							}
						},
						messages:{
							senhaAtual:{ required: '<b><font color=#FF0084>Este Campo é obrigatorio</font></b>' , remote: '<b><b><font color=#FF0084>A senha informado não corresponde!</font></b>'}
						}

					});
				}));
		});
	});
});

$(document).ready(function(){
	$('.alteralLogin').click(function(){
	$('#dialog-AlterarLog').load("CadWindows",{
		//var codigo = $(this).attr("value")
		tipo: "alterarLogin",
		codigo:$("#Logado").val()
	},function(){$('#tab').tabs(),
	
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			var codigoLog = $( "#codigoLog" ),	
			NovaSenha = $( "#NovaSenha" ),
			campos = $( [] ).add( codigoLog ).add( NovaSenha ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}

			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( "Tamanho da " + n + " deve estar entre " +
						min + " e " + max + " caracteres." );
					return false;
				} else {
					return true;
				}
			}

			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			$( "#dialog-AlterarLog" ).dialog({
				autoOpen: false,
				height: 230,
				minHeight: 230,
				maxHeight: 230,
				width: 270,
				minWidth: 270,
				maxWidth: 270,
				modal: true,
				buttons: {
					"Salvar": function() {
						var bValid = true;
						campos.removeClass( "ui-state-error" );

						bValid = bValid && checkLength( NovaSenha, " senha ", 6, 20 );
						//bValid = bValid && checkLength( nome, "nome deve ter ", 1, 50 );
						//bValid = bValid && checkLength( email, "email", 6, 80 );
						//bValid = bValid && checkLength( password, "password", 5, 16 );

						//bValid = bValid && checkRegexp( nome, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
						// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
						//bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "ex. wk@wainks.com" );
						//bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

						if ( bValid ) {
							
							$(function(){
								 $.post("AlterarLogin",{codigoLog: codigoLog.val(), NovaSenha: NovaSenha.val()
							        },$('.conteudoTable').load("MessagemAlteracao",{
							    		codigo: "Alterar"
							    	}));
							   });
							$( this ).dialog( "close" );
						} 
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				},
				close: function() {
					campos.val( "" ).removeClass( "ui-state-error" );
				}
			});
					$( "#dialog-AlterarLog" ).dialog( "open" );
					
				});
		});
	});
});


$(document).ready(function(){
	$('.Logout').click(function(){
		$(function() {
			// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$( "#dialog-confirm" ).html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 10px 25px 0;"></span>Conformar Logout?</p>');
			$( "#dialog-confirm" ).dialog({
				resizable: false,
				modal: true,
				buttons: {
					"Confirmar": function() {
						$.post("LogoutSystem",{Logado: $("#Logado").val(), eMail: $("#eMail").val()});
						$( this ).dialog( "close" );
					},
					"Cancelar": function() {
						$( this ).dialog( "close" );
					}
				}
			});
		});
	});
});

//http://www.emersoncarvalho.com/jquery-validation-campo-unico/
$(document).ready(function(){
	$('#formulario').validate({
		rules:{
			senhaAtual:{ required: true, remote: 'VerificaLogin?codigo='+$('#codigoLog').val()+'&' }
		},
		messages:{
			senhaAtual:{ required: 'Este Campo é obrigatorio' , remote: 'A senha informado não corresponde!'}
		}

	});
});

$(document).ready(function() {
	$('#tabela').dataTable( {
		"sDom": '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>'
	} );
} );*/